This chapter describes how to register and configure Jersey 2.5.1 Java API for RESTful Web Services (JAX-RS) 2.0 Reference Implementation (RI) for use with WebLogic Server 12.1.3.
This chapter includes the following sections:
Registering the Jersey 2.5.1 (JAX-RS 2.0 RI) Shared Library With Your WebLogic Server Instances
Configuring the Web Application to Use Jersey 2.5.1 (JAX-RS 2.0 RI)
WebLogic Server ships with a pre-built shared library, packaged as a Web application, that is required to run applications that are based on Jersey 2.5.1 (JAX-RS 2.0 RI). To take advantage of Jersey 2.5.1 (JAX-RS 2.0 RI) features, you need to register the shared library and configure your Web applications, as described in the following sections:
Registering the Jersey 2.5.1 (JAX-RS 2.0 RI) Shared Library With Your WebLogic Server Instances
Configuring the Web Application to Use Jersey 2.5.1 (JAX-RS 2.0 RI)
Note:
RESTful web services and clients that are built using Jersey 2.5.1 (JAX-RS 2.0 RI) cannot be secured using Oracle Web Services Manager (OWSM) policies in this release.Shared Java EE libraries are registered with one or more WebLogic Server instances by deploying them to the target servers and indicating that the deployments are to be shared. Shared Java EE libraries must be targeted to the same WebLogic Server instances you want to deploy applications that reference the libraries.
When a referencing application is deployed, WebLogic Server merges the shared library files with the application. If you try to deploy a referencing application to a server instance that has not registered a required library, deployment of the referencing application fails.
The following sections describe how to register Jersey 2.5.1 (JAX-RS 2.0 RI) shared library with your WebLogic Server instances using the following tools:
For each WebLogic Server instance to which you want to deploy Jersey 2.5.1 (JAX-RS 2.0 RI) applications, perform the following steps:
Log into the WebLogic Server Administration Console as described in "Accessing Oracle WebLogic Administration Console" in Administering Web Services with Oracle Fusion Middleware.
For example:
http://
host:port
/console
Select Deployments.
Click Install to install the shared library.
In the Path field, enter or navigate to the following directory: MW_HOME\wlserver\common\deployable-libraries.
Select the jax-rs-2.0.war file.
Click Next.
Select Install this deployment as a library.
Click Next.
Click Finish.
For each WebLogic Server instance to which you want to deploy Jersey 2.5.1 (JAX-RS 2.0 RI) applications, perform the following steps:
Invoke WLST, as described in "Invoking WLST" in Understanding the WebLogic Scripting Tool.
For example:
c:\Oracle\Middleware\wlserver\common\bin> wlst.cmd
Connect to the running instance using the connect
command.
For example:
wls:/offline> connect('weblogic', 'welcome1', 't3://localhost:7001')
For more information, see "connect" in WLST Command Reference for WebLogic Server
Deploy the shared library using the deploy
command.
For example:
wls:/base_domain/serverConfig> deploy('jax-rs', 'c:\Oracle\Middleware\wlserver\common\deployable-libraries\jax-rs-2.0.war', libraryModule='true')
For more information, see "deploy" in WLST Command Reference for WebLogic Server.
Exit the WLST command session, as follows:
wls:/base_domain/serverConfig> exit()
For each WebLogic Server instance to which you want to deploy Jersey 2.5.1 (JAX-RS 2.0 RI) applications, add an Ant task similar to the following to the build script:
<taskdef name="wldeploy" classname="weblogic.ant.taskdefs.management.WLDeploy" /> <target name="deploy.jaxrs.2.0"> <wldeploy action="deploy" source="${mw.home}/wlserver/common/deployable-libraries/jax-rs-2.0.war" name="jax-rs" user="${user}" password="${passwd}" adminurl="t3://${webServerHost}:${webServerPort}" verbose="true" targets="myserver" library="true" /> </target>
For each WebLogic Server instance for which you want to deploy JAX-RS 2.5.1 applications, use weblogic.Deployer
to deploy the shared library files to the required target servers, and identify the deployment as a library using the -library
option.
The following shows an example of how to deploy the Jersey 2.5.1 (JAX-RS 2.0 RI) shared library using weblogic.Deployer
:
java weblogic.Deployer -verbose -noexit -source C:\Oracle\Middleware\wlserver\common\deployable-libraries\jax-rs-2.0.war -targets myserver -adminurl t3://localhost:7001 -user weblogic -password ******** -deploy -library
You need to configure the Web application that contains the RESTful web services to use the Jersey shared libraries. Specifically, you need to update the weblogic.xml
deployment descriptor files that are associated with your application to reference the shared library. The weblogic.xml
file is located in the WEB-INF
directory in the root directory of your application archive.
The following example shows how to update the weblogic.xml
file to use Jersey 2.5.1 (JAX-RS 2.0 RI).
<?xml version="1.0" encoding="UTF-8"?> <wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.7/weblogic-web-app.xsd"> <wls:library-ref> <library-name>jax-rs</library-name> <specification-version>2.0</specification-version> <exact-match>false</exact-match> </wls:library-ref> </wls:weblogic-web-app>